/*
 * @Author: xxx
 * @Description:
 */
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import vueJsx from "@vitejs/plugin-vue-jsx";
const Timestamp = new Date().getTime(); //随机时间戳
//引入插件
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
export default defineConfig({
  base:"./",
  build: {
    chunkSizeWarningLimit: 6000,
    sourcemap: false, // 输出.map文件,默认是false
    rollupOptions: {
      output: {
        chunkFileNames: `static/js/[name].[hash]${Timestamp}.js`,
        entryFileNames: `static/js/[name].[hash]${Timestamp}.js`,
        assetFileNames: `static/[ext]/[name].[hash]${Timestamp}.[ext]`,
      },
    },
  },
  plugins: [
    vue(),
    vueJsx(),
    Components({
      resolvers: [ElementPlusResolver({ importStyle: "sass" })],
    }),
    //配置插件
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    //  // 按需定制主题配置
    // ElementPlus({
    //   useSource: true,
    // }),
  ],
  resolve: {
    // 配置路径别名
    alias: {
      "@": resolve(__dirname, "./src"),
      jquery: "jquery/dist/jquery.min.js",
      bootstrap: "bootstrap/dist/js/bootstrap.bundle.min.js",
      Bootstrap: "bootstrap/dist/css/bootstrap.min.css",
    },
  },
  // 设置api代理
  server: {
    port: 8080,
    proxy: {
      "/api": "http://47.106.217.99:8001/", // 替换成你的域名
    },
    host: '0.0.0.0'
  },
  css: {
    preprocessorOptions: {
        scss: {
          silenceDeprecations: ['legacy-js-api']
        }
    },
    postcss: {
      plugins: [
        {
          postcssPlugin: "internal:charset-removal",
          AtRule: {
            charset: (atRule) => {
              if (atRule.name === "charset") {
                atRule.remove();
              }
            },
          },
        },
      ],
    },
  },
});
